<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" class="username">
    <input type="text" class="password">
    <input type="checkbox" class="remember"> 七天免登陆
    <input type="button" class="regist" value="登录" />
    <script src="com.js"></script>
    <script>
        document.querySelector('.regist').addEventListener('click',()=>{
            let username = document.querySelector('.username').value;
            let password = document.querySelector('.password').value;
            ajax({
                url:'http://phpclub.org.cn/edu/server/login.php',
                type:'post',
                data:{mobile:username,password},
                success: function(response){
                    if(response.code !=100){
                        alert(response.msg);
                        return;
                    }
                    let isRememver = document.querySelector('.remember').checked;
                    let expires = 0;
             
                    isRememver&&  (expires = 7*24*3600);
                    setCookie('userInfo',JSON.stringify(response.data),expires);
                 
                    let back = getUrlParam('back');
                    if(back){
                    
                        location.href = decodeURIComponent(back);
                    }else{
                        location.href = 'index.html';
                    }
                    
                }
            });

        })
    </script>
</body>
</html>